<template>
	<view class="wrap bg-white">
		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="cuIcon-titles text-bold ">选择日期</text>
			</view>
		</view>
		
		<view>
			<view class="padding bg-white">
				<view class="flex">
					<view class="flex-treble   radius">
						<u-form-item label="" prop="time" label-width="200" :label-style="{'font-weight':'bold'}">
						       <u-input placeholder="开始日期" v-model="ldate" type="select" :select-open="ldatepickerTime" @click="ldatepickerTime = true"></u-input>
						</u-form-item>
						<u-picker mode="time" v-model="ldatepickerTime" @confirm="timeConfirm"></u-picker>
					</view>
					<view class="flex-sub  padding-lg radius">
						<text class="content text-lg text-bold ">-</text>
					</view>
					<view class="flex-treble  radius">
						<u-form-item label="" prop="time" label-width="200" :label-style="{'font-weight':'bold'}">
							<u-input placeholder="结束日期" v-model="rdate" type="select" :select-open="rdatepickerTime" @click="rdatepickerTime = true"></u-input>
						</u-form-item>
						<u-picker mode="time" v-model="rdatepickerTime" @confirm="timeConfirm2"></u-picker>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="content text-lg text-bold ">总计：{{num}} 箱 {{qty}} 罐</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ldate:'',
				ldatepickerTime: false,//控制日期显示rTime: false,//控制日期显示
				rdate:'',
				rdatepickerTime: false,//控制日期显示rTime: false,//控制日期显示
				num:0,
				qty:0,
				list:[],
			}
		},
		onLoad() {
			var date = new Date();
			var year = date.getFullYear();
			var month = date.getMonth() + 1;
			var day = date.getDate();
			month >= 1 && month <= 9 ? (month = "0" + month) : "";
			day >= 0 && day <= 9 ? (day = "0" + day) : "";
			var timer = year + '-' + month + '-' + day ;
			this.ldate = timer;
			this.rdate = timer;
			this.findQtyList();
		},
		methods: {
			timeConfirm(e){
				this.ldate = e.year + '-' + e.month + '-' + e.day;
				this.list = [];
				this.num = 0;
				this.qty = 0;
				this.findQtyList();
			},
			timeConfirm2(e){
				this.rdate = e.year + '-' + e.month + '-' + e.day;
				this.list = [];
				this.num = 0;
				this.qty = 0;
				this.findQtyList();
			},
			//调用方法
			findQtyList(){
				if(this.ldate != '' && this.rdate != ''){
					var _this = this;
					var query = {
						ldate:_this.ldate,
						rdate:_this.rdate,
					};
					_this.$u.api.box.findrkQtyList(query).then(res=>{
						if(res.result == 'true'){
							_this.num = res.num;
							_this.qty = res.qty;
						}else{
							this.$u.toast(res.message);
						}
					})
				}
			},
		}
	}
</script>

<style>

</style>
